package user_service

import (
	"data_monitor/dao"
	"data_monitor/pkg/user/user_dao"
	"data_monitor/pkg/user/user_model"
	"fmt"
)

func SignIn(m *user_model.User) (*user_model.User, error) {
	tx := dao.GetDB()

	user, err := user_dao.GetUserByName(tx, m.Name)
	if err != nil{
		return nil, err
	}

	if user.Password != m.Password {
		return nil, fmt.Errorf("username or password error")
	}

	return user, err
}